package com.kcs.dc.report.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import com.kcs.common.framework.GenericAbstractAction;
import com.kcs.common.framework.GenericForm;
import com.kcs.common.utils.Constant;
import com.kcs.dc.report.model.logic.headermenuBL;

public final class LoginAction extends GenericAbstractAction {

	protected void executeScreenPreProcess(ActionMapping mapping,
			GenericForm srcform, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
	}

	protected void executeScreenPostProcess(ActionMapping mapping,
			GenericForm srcform, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		HttpSession session = null;

		System.out.println("TEST ACTION");
		
		// Set UserId and UserName, LastAccessTime, MenuList to session.
		if (srcform.getMessage().equals("")
				&& !srcform.getUserId().equals("")) {
			session = request.getSession(true);
			session.setAttribute(Constant.SESSION_USERID, srcform.getUserId());
			session.setAttribute(Constant.SESSION_PASSWORD, srcform.getPasswordEncode());
			session.setAttribute(Constant.SESSION_USERNAME, srcform.getUserName());
			session.setAttribute(Constant.SESSION_ACCESSTIME, srcform.getLastaccessTime());
			
			headermenuBL headerMenu= new headermenuBL();
			srcform.setMenuList(headerMenu.builtmenu(srcform.getUserId()));
			session.setAttribute(Constant.SESSION_AUTHORIZEDMENULIST, srcform.getMenuList());
		}
	}
};

